/*
 * Copyright (c) 2023 Cshoo Org. All Rights Reserved.
 */

package org.cshoo.tattoo.embed.infra.utils;

import org.cshoo.tattoo.embed.infra.entity.User;

/**
 * @author 杨翼
 * @since 1.0
 */
public class UserUtils {

    private static final ThreadLocal<User> USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置用户
     *
     * @param user 用户
     */
    public static void setUser(User user) {
        USER_THREAD_LOCAL.set(user);
    }

    /**
     * 获取当前用户
     *
     * @return 用户
     */
    public static User getUser() {
        return USER_THREAD_LOCAL.get();
    }
}
